package com.briup.day18;

import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/**
 * 数据库信息工具类
 * 补全代码，实现工具类获取配置文件信息
 * @author lining
 * @date 2024/1/30 15:00
 */
public class DbUtils {
    //静态成员变量属性 如何赋值？直接赋值  静态代码块赋值
    private static Properties properties;
    static{
        properties = new Properties();
        try {
            properties.load(new FileReader("db.properties"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private DbUtils(){

    }

    public static String getUserName(){
        return properties.getProperty("username");
    }
    public static String getPassword(){
        return properties.getProperty("password");
    }
    public static String getUrl(){
        return properties.getProperty("url");
    }
    public static String getDriver(){
        return properties.getProperty("driver");
    }
}
